[builders] Switch Vercel Build Output API from CJS to ESM#1562
[builders] Switch Vercel Build Output API from CJS to ESM#1562VaguelySerious wants to merge 2 commits intomainfrom
Conversation
The step, workflow, and webhook bundles produced by VercelBuildOutputAPIBuilder and the standalone builder now default to ESM format instead of CJS. This preserves native import.meta.url support, fixing issues with libraries like Prisma that rely on it. The intermediate workflow bundle (which runs inside vm.runInContext) remains CJS — the only place where CJS is genuinely required. Closes #1507 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: ab40104 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests🌍 Community Worlds (60 failed)mongodb (3 failed):
redis (2 failed):
turso (55 failed):
Details by Category✅ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
✅ 📋 Other
|
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) workflow with 1 step💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) workflow with 25 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) workflow with 50 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) Promise.all with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) Promise.race with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) workflow with 10 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) workflow with 25 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) workflow with 50 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) workflow with 10 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) workflow with 25 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) workflow with 50 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) stream pipeline with 5 transform steps (1MB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) 10 parallel streams (1MB each)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) fan-out fan-in 10 streams (1MB each)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
❌ Some benchmark jobs failed:
Check the workflow run for details. |
Fully-bundled ESM output needs a real `require` function for CJS dependencies that call require() on Node.js builtins (e.g. debug requiring tty). Add a createRequire banner to the steps, workflow, and webhook bundles. Also update the CLI standalone config to output .mjs files, and update world-testing to import from the new .mjs paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
VercelBuildOutputAPIBuildernow emits.mjsfiles with"type": "module"inpackage.jsonand"handler": "index.mjs"in.vc-config.jsonStandaloneBuilderinherits the new ESM defaults automaticallyvm.runInContext) remains CJS — the only place where CJS is genuinely requiredimport.meta.urlpolyfill from the webhook bundle (no longer needed with ESM output)Motivation
Every framework-specific local builder (Next.js, SvelteKit, Astro, NestJS, Nitro, Vitest) already overrides the format to ESM. The Vercel Build Output API builder and standalone builder were the only ones still defaulting to CJS, which caused
import.meta.urlto be undefined at runtime — breaking libraries like Prisma that rely on it (#1507).The CJS polyfill from #1509 fixed the symptom but this PR fixes the root cause: there's no reason these bundles need CJS since Vercel serverless functions fully support ESM.
Supersedes #1509.
Test plan
@workflow/builderstests pass (115/115)@workflow/coretests pass (499/499)"type": "module"and"handler": "index.mjs"__import_meta_url) and uses native ESMCloses #1507
🤖 Generated with Claude Code